home *** CD-ROM | disk | FTP | other *** search
/ Ham Radio 2000 #1 / Ham Radio 2000.iso / ham2000 / packet / p_aa4re / bb212src / bbwaketc.pas < prev    next >
Encoding:
Pascal/Delphi Source File  |  1992-02-16  |  4.6 KB  |  151 lines

  1. (*===========================================================================*)
  2. (* Wakeup time checker                                                       *)
  3. (*                                                                           *)
  4. (*   Copyright 1988, 1989 by H. Roy Engehausen.  All rights reserved.        *)
  5. (*                                                                           *)
  6. (*===========================================================================*)
  7.  
  8. (*===========================================================================*)
  9. (* Wakeup line processor                                                     *)
  10. (*===========================================================================*)
  11.  
  12. PROCEDURE time_check;
  13.  
  14.   VAR
  15.     code      : INTEGER;
  16.     i         : INTEGER;
  17.     next_hour : BOOLEAN;
  18.     s         : STRING[3];
  19.  
  20. {$UNDEF DEBUG_TC}
  21.  
  22.   BEGIN;
  23.  
  24.     time_ok := FALSE;
  25.  
  26.     IF time_increment AND (POS('=', action_time_str) > 0) THEN
  27.       BEGIN;
  28.         window_write('WKE:',
  29.                           'Invalid WAKEUP time (+==) on line #' + line_no_str);
  30.         EXIT;
  31.       END;
  32.  
  33.     (*-----------------------------------------------------------------------*)
  34.     (* Convert action time to ticks since midnight                           *)
  35.     (*-----------------------------------------------------------------------*)
  36.  
  37.     colon_pos := POS(':', action_time_str);
  38.  
  39.     IF (colon_pos = 1) OR (colon_pos = LENGTH(action_time_str)) THEN
  40.       BEGIN;
  41.         window_write('WKE:',
  42.               'Invalid WAKEUP time (colon position) on line #' + line_no_str);
  43.         EXIT;
  44.       END;
  45.  
  46.     IF colon_pos > 0 THEN
  47.       DEC(colon_pos);
  48.  
  49.     (*-----------------------------------------------------------------------*)
  50.     (* Get the HOURS field                                                   *)
  51.     (*-----------------------------------------------------------------------*)
  52.  
  53.     s := substr(action_time_str, 1, colon_pos);
  54.  
  55.     IF s <> '==' THEN
  56.       BEGIN;
  57.  
  58.         eq_sw := FALSE;
  59.  
  60.         VAL(s, i, code);
  61.  
  62.         IF (code <> 0) OR (i < 0) OR (i > 23) THEN
  63.           BEGIN;
  64.             window_write('WKE:',
  65.                         'Invalid WAKEUP time (hours) on line #' + line_no_str);
  66.             EXIT;
  67.           END;
  68.  
  69.         hr := i;
  70.  
  71.       END
  72.     ELSE
  73.       BEGIN;
  74.  
  75.         eq_sw := TRUE;
  76.  
  77.         IF colon_pos = 0 THEN
  78.           BEGIN;
  79.             window_write('WKE:',
  80.                            'Invalid WAKEUP time (==) on line #' + line_no_str);
  81.             EXIT;
  82.           END;
  83.  
  84.         next_hour := COPY(last_time_str, 8, 2) = COPY(todays_date_time, 8, 2);
  85.  
  86.       END;
  87.  
  88.     (*-----------------------------------------------------------------------*)
  89.     (* Get the MINUTES FIELD                                                 *)
  90.     (*-----------------------------------------------------------------------*)
  91.  
  92.     IF colon_pos > 0 THEN
  93.       BEGIN;
  94.  
  95.         (*-------------------------------------------------------------------*)
  96.         (*  Minutes exist                                                    *)
  97.         (*-------------------------------------------------------------------*)
  98.  
  99.         s := COPY(action_time_str, colon_pos+ 2, 255);
  100.  
  101.         VAL(s, i, code);
  102.  
  103.         IF (code <> 0) OR (i < 0) OR (i > 59) THEN
  104.           BEGIN;
  105.             window_write('WKE:',
  106.                  'Invalid WAKEUP time (minutes) on line #' + line_no_str);
  107.             EXIT;
  108.           END;
  109.  
  110.       END
  111.     ELSE
  112.       i := 0;
  113.  
  114.     time_ok := TRUE;
  115.  
  116.     IF eq_sw THEN
  117.       BEGIN;
  118.  
  119.         (*-------------------------------------------------------------------*)
  120.         (* Hours were '=='... Minutes were not                               *)
  121.         (*-------------------------------------------------------------------*)
  122.  
  123.         IF (NOT did_today AND (last_hours > 0))
  124.                  OR ((i <= last_min) AND NOT next_hour) THEN
  125.           action_time := 0
  126.         ELSE
  127.           action_time := time_next_hour(i);
  128.  
  129.         {$IFDEF DEBUG_TC}
  130.         WRITELN('==:xx ', i, ' -- ', last_min, ' -- ',
  131.                                      next_hour , ' -- ',
  132.                                      action_time, ' -- ',
  133.                                      current_day_time);
  134.         {$ENDIF}
  135.  
  136.         EXIT;
  137.  
  138.       END;
  139.  
  140.     action_time := LONGINT(hr) * ticks_per_hour + WORD(i) * ticks_per_min;
  141.  
  142.     IF time_increment AND (action_time = 0) THEN
  143.       BEGIN;
  144.         window_write('WKE:',
  145.                       'Invalid WAKEUP time increment on line #' + line_no_str);
  146.         time_ok := FALSE;
  147.         EXIT;
  148.       END;
  149.  
  150.   END;
  151.